﻿@model PrjctMngmt.Models.Message

<script type="text/javascript">
    $(function () {
        $("#topic").dialog({
            autoOpen: false, width: 400, modal: true,
            buttons: {
                "Save": function () {
                    $.post("/Topic/Create",
                        $("#TopicForm").serialize(),
                        function () {
                            $("#topic").dialog("close");
                            window.location.reload();
                        });
                },
                Cancel: function () { $(this).dialog("close"); }
            }
        });
        $(".addTopic").click(function () {
            $("#topic").html("")
                .dialog("option", "title", "Create topic")
                .load("/Topic/Create", function () { $("#topic").dialog("open"); });
        });
    });
</script>

<script type="text/javascript" >
    $(document).ready(function () {
        $("#editor").markItUp(mySettings);
    });
</script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Message</legend>

        <p>All fields required.</p>

        <div class="editor-label">
            Message
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.Data, new { @cols = 60, @rows = 10, @id = "editor" })
            @Html.ValidationMessageFor(model => model.Data)
        </div>

        <div class="editor-label">
            Topic
        </div>
        <div class="editor-field">
            @Html.DropDownList("TopicID", (IEnumerable<SelectListItem>)ViewData["Topics"], "")
            <img alt="Create topic" class="addTopic ButtonLink Top" src="../../Content/themes/base/images/plus-sign_small.png" />
        </div>
        
        <p>
            <input type="submit" value="Submit" />
        </p>

        <div id="topic"></div>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
